class Solution(object):
    def minimizeError(self, prices, target):
        """
        :type prices: List[str]
        :type target: int
        :rtype: str
        """
        min_value = 0
        max_value = 0
        n = len(prices)
        down = []
        for price in prices:
            price = float(price)
            min_value += int(price)
            down.append(round(price - int(price), 3))
            if int(price) == price:
                max_value += int(price)
            else:
                max_value += (int(price) + 1)
        total = 0
        if min_value <= target <= max_value:
            k = max_value - target
            down.sort()
            count = 0
            for i in range(n):
                if down[i] != 0:
                    if count < k:
                        total += down[i]
                        count +=1
                    else:
                        total += (1 - down[i])
            total = round(total, 3)
            if total == 0:
                return '0.000'
            total = str(total)
            k = len(total.split('.')[-1])
            if k < 3:
                total += '0' * (3 - k)
            return total
        else:
            return '-1'






data = Solution()
prices = ["0.700","2.800","4.900"]
target = 8
print(data.minimizeError(prices, target))